﻿
var offsetxpoint = 15
var offsetypoint = 5
var ie = document.all
var ns6 = document.getElementById && !document.all
var enabletip = false
var tipobj;

function GetDIV(divID) {
    var divObj;
    var item = document.all? document.all[divID] : document.getElementById? document.getElementById(divID) : ""
    if (typeof(item) != 'undefined') {
        divObj = item;
    }
    if (!divObj) {
        try {
            var tmp_divObj = document.createElement('div');
            tmp_divObj.setAttribute('id', divID);
            tmp_divObj.setAttribute('align', 'left');
            tmp_divObj.setAttribute('valign', 'top');
            tmp_divObj.style.width = '0px';
            tmp_divObj.style.Height = '0px';
            tmp_divObj.style.visibility = "hidden";
            divObj = document.body.appendChild(tmp_divObj);
        } catch(E) {
            var divHTML = '\<div id="' + divID + '" name="' + divID + "' style='visibility:hidden'";
            divHTML += 'width:0px;';
            divHTML += 'height:0px;';
            divHTML += '"><\/div>';
            document.body.innerHTML += divHTML;
            divObj = document.all? document.all[divID] : document.getElementById? document.getElementById(divID) : ""
        }
    }
    return divObj;
}

function hideselectboxes_underTip(tipobj) {
    var selx,sely,selw,selh,i
    if (!document.sel) {
        document.sel = document.getElementsByTagName("SELECT")
        document.sel.level = 0
    }
    var l = 0;
    var sel = document.sel
    for (i = 0; i < sel.length; i++) {
        selx = 0;
        sely = 0;
        var selp;
        if (sel[i].offsetParent) {
            selp = sel[i];
            while (selp.offsetParent) {
                selp = selp.offsetParent;
                selx += selp.offsetLeft;
                sely += selp.offsetTop;
            }
        }
        selx += sel[i].offsetLeft;
        sely += sel[i].offsetTop
        selw = sel[i].offsetWidth;
        selh = sel[i].offsetHeight

        if (selx + selw > tipobj.offsetLeft
                && selx < tipobj.offsetLeft + tipobj.offsetWidth
                && sely + selh > tipobj.offsetTop && sely < tipobj.offsetTop + tipobj.offsetHeight) {
            var cur_visibility =  (sel[i].style.visibility)?(sel[i].style.visibility):"visible";
            if (sel[i].style.visibility != "hidden") {
                sel[i].level = l;
                sel[i].style.visibility = "hidden";
                if (tipobj) {
                    if (!tipobj.mout) tipobj.mout = "";
                    tipobj.mout +=  "document.sel[" + i + "].style.visibility='" +cur_visibility +"';"
                }
            }
        } else if (l <= sel[i].level && !(tipobj && l == 0)) sel[i].style.visibility = "visible"
    }
}

function ietruebody() {
    return (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
}
function ddrivetip(thetext, backgroundColor, thewidth, borderStyle) {
    if (!tipobj) tipobj = GetDIV('itemdescription');
    if (ns6 || ie) {
        if (typeof thewidth != "undefined" && thewidth != "") tipobj.style.width = thewidth + "px";
        if (typeof backgroundColor != "undefined" && backgroundColor != "") tipobj.style.backgroundColor = backgroundColor;
        if (typeof borderStyle != "undefined" && borderStyle != "") tipobj.style.border = borderStyle;

        if (thetext == "") return false
        tipobj.innerHTML = thetext
        enabletip = true
        return false
    }
}
function positiontip(e) {
    if (!tipobj) tipobj = GetDIV('itemdescription');
    if (enabletip) {
        var curX = (ns6)?e.pageX : event.clientX + ietruebody().scrollLeft;
        var curY = (ns6)?e.pageY : event.clientY + ietruebody().scrollTop;
        var rightedge = ie && !window.opera? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20
        var bottomedge = ie && !window.opera? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20
        var leftedge = (offsetxpoint < 0)? offsetxpoint * (-1) : -1000
        if (rightedge < tipobj.offsetWidth)
            tipobj.style.left = ie? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - tipobj.offsetWidth + "px"
        else if (curX < leftedge)
            tipobj.style.left = "5px"
        else
            tipobj.style.left = curX + offsetxpoint + "px"
        if (bottomedge < tipobj.offsetHeight)
            tipobj.style.top = ie? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + "px" : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + "px"
        else
            tipobj.style.top = curY + offsetypoint + "px"
        tipobj.style.visibility = "visible"

        hideselectboxes_underTip(tipobj);

    }
}
function hideddrivetip() {
    if (!tipobj) tipobj = GetDIV('itemdescription');
    if (ns6 || ie) {
        enabletip = false;
        tipobj.style.visibility = "hidden";
        tipobj.style.left = "-1000px";
        tipobj.style.backgroundColor = '';
        tipobj.style.width = '';
        tipobj.style.border = '1px solid';
        if (tipobj.mout) eval(tipobj.mout);
        tipobj.mout="";
    }
}
document.onmousemove = function() {
    if (tipobj) {
        positiontip();
    }
}


